/********************************************************************************
* File Name          : BMP085.h
* Author             : Jon Henry
* Version            : $Revision:$
* Date               : $Date:$
* Description        : Descriptor Header for BMP085 driver file
*                    : I2C protocols based on Standard Peripherals
*                    : Library Version 1.1.0
*
* HISTORY:
* Date        | Modification                                | Author
*
*******************************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __BMP085
#define __BMP085

/* Includes ------------------------------------------------------------------*/
#include <stm32f4xx_i2c.h>
#include <math.h>
/* Exported types ------------------------------------------------------------*/
//these could change accordingly with the architecture
typedef unsigned char u8_t;
typedef unsigned short int u16_t;
typedef unsigned int u32_t;
typedef short int i16_t;
typedef int i32_t;
typedef float float32_t;
typedef u8_t IntPinConf_t;
typedef u8_t Axis_t;
typedef u8_t IntConf_t;

#ifndef __SHARED__TYPES
#define __SHARED__TYPES

typedef enum {
  MEMS_SUCCESS				=		0x01,
  MEMS_ERROR				=		0x00
} status_t;

typedef enum {
  MEMS_ENABLE				=		0x01,
  MEMS_DISABLE				=		0x00
} State_t;

#endif /*__SHARED__TYPES*/


/* Exported constants --------------------------------------------------------*/
/* The address of the device is normally given as a 7-bit address by the
 * manufacturer. in the case of the STMicro L3GD20 Gyroscope, the manufacturer
 * lists the address as 110101xb. the x-bit is set by tying the SDO pin either
 * high or low. If the SDO pin is tied high, the address becomes 1101011b (0x6B),
 * if tied low it becomes 1101010b (0x6A).
 * As you know with I2C, to achieve a full 8-bit address and expedite
 * functionality, the 7-bit address is shifted left by one and the new LSB is then
 * used to tell the slave whether the master is writing (LSB = 0) or reading
 * (LSB = 1) from the slave.
 * In this driver, the functions are written such the the slave device address
 * shall be defined as SLAVE_ADDRESS << 1.
 *
 * I.E.  L3GD20 Slave address(SDO tied high) = 1101011b = 0x6C  therefore,
 *       #define L3GD20_MEMS_I2C_ADDRESS = 1101011 << 1 = 11010110b = 0xD6
 *
 * I.E.  L3GD20 Slave address(SDO tied low) = 1101010b = 0x6B  therefore,
 *       #define L3GD20_MEMS_I2C_ADDRESS = 1101010 << 1 = 11010100b = 0xD4
 *
 * There is no need to worry about the new LSB/RW bit. The read and write
 * functions in the 'device'.c file will set that bit appropriately.
 */
#define BMP085_I2C_ADDRESS      0xEE
#define OSS						0x00

/**************ACCELEROMETER REGISTER*****************/

// CONTROL REGISTER
#define CTRL_REG				0xF4

// CONTROL REGISTER VALUES
#define TEMP					0x2E
#define PRESS_0					0x34
#define PRESS_1					0x74
#define PRESS_2					0xB4
#define PRESS_3					0xF4

// TEMPERATURE OR PRESSURE VALUE
#define TEMPPRESS_H				0xF6
#define TEMPPRESS_L				0xF7
#define TEMPPRESS_XL			0xF8

// CALIBRATION REGISTER ADDRESSES
#define AC1_H					0xAA
#define AC1_L					0xAB
#define AC2_H					0xAC
#define AC2_L					0xAD
#define AC3_H					0xAE
#define AC3_L					0xAF
#define AC4_H					0xB0
#define AC4_L					0xB1
#define AC5_H					0xB2
#define AC5_L					0xB3
#define AC6_H					0xB4
#define AC6_L					0xB5
#define B1_H					0xB6
#define B1_L					0xB7
#define B2_H					0xB8
#define B2_L					0xB9
#define MB_H					0xBA
#define MB_L					0xBB
#define MC_H					0xBC
#define MC_L					0xBD
#define MD_H					0xBE
#define MD_L					0xBF

/* Exported macro ------------------------------------------------------------*/
#define ValBit(VAR,Place)         (VAR & (1<<Place))
#define BIT(x) ( (x) )

/* Exported functions --------------------------------------------------------*/
//Sensor Configuration Functions
status_t BMP085_Init();
status_t BMP085_SetTemperature(State_t state);
status_t BMP085_GetTempRaw(i16_t* val);

//Generic
//u8_t ReadReg(u8_t Reg, u8_t* Data);
//u8_t WriteReg(u8_t Reg, u8_t Data);

u8_t BMP085_ReadReg(u8_t Reg, u8_t* Data);
status_t BMP085_ReadCalReg(u8_t Reg);
u8_t BMP085_WriteReg(u8_t Reg, u8_t Data);


#endif /* __BMP085_H */

/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
